package com.liveinstars.demo;

import com.alibaba.fastjson.JSONObject;
import com.liveinstars.api.demo.HelloService;
import com.liveinstars.api.demo.model.HelloEnum;
import com.liveinstars.api.demo.model.HelloReq;
import com.liveinstars.api.demo.model.HelloRes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 为了将网络层和service层拆分，EndPoint在获取网络层参数后，业务逻辑委托Service层实现。
 * Created by guoyanjiang on 2018/11/26.
 */
@RestController
public class ProviderEndPoint implements HelloService {

    @Autowired
    @Qualifier("providerServiceImpl")
    HelloService helloService;


    @Override
    public String hello(@RequestParam("str") String strxxx) {
        return helloService.hello(strxxx);
    }

    @Override
    public HelloRes helloWorld(@RequestBody HelloReq req) {
        return helloService.helloWorld(req);
    }

    @Override
    public HelloRes helloMix(@RequestBody HelloReq req, @RequestParam("str") String strxxx) {
        return helloService.helloMix(req, strxxx);
    }

    @Override
    public HelloRes helloFastjson(@RequestBody JSONObject req, @RequestParam("str") String str) {
        return helloService.helloFastjson(req, str);
    }

    @Override
    public boolean testBoolean() {
        return helloService.testBoolean();
    }

    @Override
    public void testVoid() {
        helloService.testVoid();
    }

    @Override
    public int testInt(int num) {
        return helloService.testInt(num);
    }

    @Override
    public HelloEnum testEnum(@RequestBody HelloEnum helloEnum) {
        return helloService.testEnum(helloEnum);
    }

    @Override
    public void testCallBack(@RequestBody CallBack callBack) {
        helloService.testCallBack(callBack);
    }

    @Override
    public void testException() {
        helloService.testException();
    }
}
